﻿using Admin2024.Application.Contracts.User;
using Admin2024.Domain.IDomainService.System.IUserService;
using Admin2024.Domain.ObjValue;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Admin2024.Application.User
{
    public class AppUserRoleService : IAppUserRoleService
    {
        private readonly IUserRoleManagementService _appUserRoleService;
        public AppUserRoleService(IUserRoleManagementService appUserRoleService)
        {
            this._appUserRoleService = appUserRoleService;
        }
        //给用户分配角色
        public async Task<DomainResult<string>> AssignRoleToUser(Guid appUserId, Guid appRoleId)
        {
            var appUserRole = await _appUserRoleService.AssignRoleToUser(appUserId, appRoleId);

            if (!appUserRole.IsSuccess)
            {
                return DomainResult<string>.Error(appUserRole.Message);
            }

            return DomainResult<string>.Success(appUserRole.Data);
        }
        //给用户删除角色
        public async Task<DomainResult<string>> RemoveRoleFromUser(Guid appUserId, Guid appRoleId)
        {
            var appUserRole = await _appUserRoleService.RemoveRoleFromUser(appUserId, appRoleId);

            if (!appUserRole.IsSuccess)
            {
                return DomainResult<string>.Error(appUserRole.Message);
            }

            return DomainResult<string>.Success(appUserRole.Data);
        }
    }
}
